$(function () {
    $('#login').on('click', function () {
        const username = $('#username').val()
        const password = $('#password').val()
        if (!username || !password) {
            layer.alert('请输入账号和密码')
            return
        }
        $.ajax({
            url: "/admin/user/login",
            type: "post",
            data: { username, password },
            success(res) {
                if (res.code === 200) {
                    localStorage.setItem('token', res.token)
                    location.href = "index.html"
                } else {
                    layer.alert('请重新输入账号和密码')
                }
            }


        })
    })
})